package com.mengye.control.courseInfo;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.mengye.bean.CourseInfoBean;
import com.mengye.bean.TeacherInfoBean;
import com.mengye.control.LoginControl;
import com.mengye.model.CourseInfoModel;
import com.mengye.utils.EasyFactory;
import com.mengye.utils.MyUtils;

/**
 * Servlet implementation class CourseInfoAjaxQuery
 */
@WebServlet("/CourseInfoOtherQueryControl")
public class CourseInfoOtherQueryControl extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		TeacherInfoBean teacherInfoB = MyUtils.convertRequest2BeanWithFileUpload(request, TeacherInfoBean.class);
		System.out.println("进入CourseInfoAjaxQueryControl");
		List<CourseInfoBean> lst = EasyFactory.getNewInstance(CourseInfoModel.class).queryOtherCourseInfo(teacherInfoB);
		System.out.println("lst2" + lst.size());
		// 把查询结果集转换为json字符串格式，借助于第三方工具 Alibaba 的 fastjson工具 （进行了日期格式转换处理）

		String strJson = JSON.toJSONStringWithDateFormat(lst, "yyyy-MM-dd HH:mm:ss",
				SerializerFeature.WriteDateUseDateFormat);

		// 获取response中的流操作对象PrintWriter
		PrintWriter pw = response.getWriter();
		// 写出内容到浏览器客户端
		pw.write(strJson);
		pw.flush();
	}

}
